<?php
/**
 * Created by PhpStorm.
 * User: CCA
 * Date: 2019/10/11
 * Time: 17:05
 */

namespace app\api\controller;


use app\api\Base2Controller;
use app\common\model\Goodsclass;
use think\Db;

/**
 * 轮播图
 * Class Banner
 * @package app\api\controller
 */
// extends BaseController
class Banner extends Base2Controller
{
    public function getBanner()
    {
        $address = intval(input('address'))?intval(input('address')):3;
        $time = time();
        $where['adv_startdate'] = ['<=',$time];
        $where['adv_enddate'] = ['>=',$time];
        $where['adv_enabled'] = 1;
        $result = Db::name('adv')->where(['adv_address'=>$address])
            ->where($where)->field('adv_id,adv_address,ap_id,adv_title,adv_link,adv_images,adv_clicknum,adv_bgcolor,artice_type,mansong_type,xianshi_type,project_type')
        ->order('adv_sort asc')
            ->select();
        $file_http = db('config')->where('code', 'qiniu_http')->find();
        foreach ($result as $k=>$v)
        {
            if ($v['adv_images']) {
                $result[$k]['adv_images'] = $file_http['value'].'/'.$v['adv_images'];
            }
        }
        return json_success_return($result);
    }



    }
